﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LY.DataAccess.Repository;
using LY.Interface;
using LY.Entity;
using LY.Common;
using LY.Common.CacheManager;
using System.Runtime.Serialization;
namespace LY.Business.ServiceImpl
{
    public class ResourceService : IResourceService
    {
        private ResourceRepository dRepo;
        public ResourceService()
        {
            dRepo = new ResourceRepository();
        }

        public List<IResource> GetResourceByCode(string code)
        {
            return GetResourceByCode(code, false);
        }
        public List<IResource> GetResourceByCode(string code, bool hasAllOption)
        {
            return GetResourceByCode(code, "", hasAllOption);
        }
        public List<IResource> GetResourceByCode(string code, string parentCode, bool hasAllOption)
        {
            object cache = CacheFactory.Instance.CreateCoreCacheInstance().Get("RESOURCE_" + code + "_" + parentCode);
            List<IResource> list = null;
            if (cache != null)
            {
                list = cache as List<IResource>;
            }
            if (list != null)
            {
                if (hasAllOption)
                    list.Insert(0, new DefaultResource() { Code = null, Name = "请选择...", Value = null });
                return list;
            }
            switch (code)
            {
                case "CustomerSource": // 客户来源：1 引入-派单、2电话-引入
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "1", Name = "引入-派单", Value = "1" });
                    list.Add(new DefaultResource() { Code = "2", Name = "电话-引入", Value = "2" });
                    break;
                case "FollowUpMode": // 跟进方式：1 接待面谈一、2接待面谈二
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "1", Name = "接待面谈一", Value = "1" });
                    list.Add(new DefaultResource() { Code = "2", Name = "接待面谈二", Value = "2" });
                    break;
                case "FollowUpStatus": // 跟进状态：1 参加公司宣讲等活动一、2参加公司宣讲等活动二
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "1", Name = "参加公司宣讲等活动一", Value = "1" });
                    list.Add(new DefaultResource() { Code = "2", Name = "参加公司宣讲等活动二", Value = "2" });
                    break;
                case "CustomerStatus": // 客户状态：1 意向客户一、2意向客户二
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "1", Name = "意向客户一", Value = "1" });
                    list.Add(new DefaultResource() { Code = "2", Name = "意向客户二", Value = "2" });
                    break;
                case "MyFriend": // 好友：1 全部好友、2全部我的会员
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "1", Name = "全部好友", Value = "1" });
                    list.Add(new DefaultResource() { Code = "2", Name = "全部我的会员", Value = "2" });
                    break;
                case "GENDER": // 性别：1 男、2女
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "1", Name = "男", Value = "1" });
                    list.Add(new DefaultResource() { Code = "2", Name = "女", Value = "2" });
                    break;
                case "GENDER2": // 性别：1 男、2女、保密
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "1", Name = "&nbsp;男&nbsp;&nbsp;&nbsp;", Value = "1" });
                    list.Add(new DefaultResource() { Code = "2", Name = "&nbsp;女&nbsp;&nbsp;&nbsp;", Value = "2" });
                    list.Add(new DefaultResource() { Code = "3", Name = "&nbsp;保密", Value = "3" });
                    break;
                case "SubProject":
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "0", Name = "否", Value = "0" });
                    list.Add(new DefaultResource() { Code = "1", Name = "是", Value = "1" });
                    break;
                case "ISTOP": // 是否置顶：1 是、0 否
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "0", Name = "否", Value = "0" });
                    list.Add(new DefaultResource() { Code = "1", Name = "是", Value = "1" });
                    break;

                case "YesOrNo": // 是否置顶：1 是、0 否
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "false", Name = "否", Value = "false" });
                    list.Add(new DefaultResource() { Code = "true", Name = "是", Value = "true" });
                    break;



                case "AuditStatus": // 审核状态：0待审核、1审核不通过、2审核通过
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "0", Name = "待审核", Value = "0" });
                    list.Add(new DefaultResource() { Code = "1", Name = "审核不通过", Value = "1" });
                    list.Add(new DefaultResource() { Code = "2", Name = "审核通过", Value = "2" });
                    break;
                case "LoanStatus": // 借款状态：0未借款、1已借款
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "0", Name = "未借款", Value = "0" });
                    list.Add(new DefaultResource() { Code = "1", Name = "已借款", Value = "1" });
                    break;
                case "RepaymentStatus": // 还款状态：0未还款、1已还款
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "0", Name = "未还款", Value = "0" });
                    list.Add(new DefaultResource() { Code = "1", Name = "已还款", Value = "1" });
                    break;
                case "LoanType": // 借款类型：0全局房招金 1全局车纳福 2全局新手
                    list = new List<IResource>();
                    //list.Add(new DefaultResource() { Code = "0", Name = "企业经营贷", Value = "0" });
                    //list.Add(new DefaultResource() { Code = "1", Name = "购房周转贷", Value = "1" });
                    //list.Add(new DefaultResource() { Code = "0", Name = "个人经营贷", Value = "2" });
                    //list.Add(new DefaultResource() { Code = "1", Name = "车辆周转贷", Value = "3" });
                    //list.Add(new DefaultResource() { Code = "1", Name = "个人消费贷", Value = "4" });
                    list.Add(new DefaultResource() { Code = "0", Name = "全局房招金", Value = "0" });
                    list.Add(new DefaultResource() { Code = "1", Name = "全局车纳福", Value = "1" });
                    list.Add(new DefaultResource() { Code = "2", Name = "全局新手", Value = "2" });
                    break;
                case "MARITALSTATUS": // 婚姻状况：1未婚 、2已婚
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "1", Name = "未婚", Value = "1" });
                    list.Add(new DefaultResource() { Code = "2", Name = "已婚", Value = "2" });
                    break;
                case "EDUCATION": // 教育程度：1高中、2本科、3硕士、4博士
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "1", Name = "高中", Value = "1" });
                    list.Add(new DefaultResource() { Code = "2", Name = "本科", Value = "2" });
                    list.Add(new DefaultResource() { Code = "3", Name = "硕士", Value = "3" });
                    list.Add(new DefaultResource() { Code = "4", Name = "博士", Value = "4" });
                    break;
                case "CARCASE": // 购车情况：1是、 2否
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "1", Name = "是", Value = "1" });
                    list.Add(new DefaultResource() { Code = "2", Name = "否", Value = "2" });
                    break;
                case "PURC": // 购房情况：1是、2否
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "1", Name = "是", Value = "1" });
                    list.Add(new DefaultResource() { Code = "2", Name = "否", Value = "2" });
                    break;
                case "QUESTIONONE": // 安全问题1：1您的小学老师？、2您父亲的生日？、3您母亲的生日？、4您的结婚纪念日？
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "1", Name = "您的小学老师", Value = "您的小学老师？" });
                    list.Add(new DefaultResource() { Code = "2", Name = "您父亲的生日", Value = "您父亲的生日？" });
                    list.Add(new DefaultResource() { Code = "3", Name = "您母亲的生日", Value = "您母亲的生日？" });
                    list.Add(new DefaultResource() { Code = "4", Name = "您的结婚纪念日", Value = "您的结婚纪念日？" });
                    break;
                case "QUESTIONTWO": // 安全问题1：1您的小学老师？、2您父亲的生日？、3您母亲的生日？、4您的结婚纪念日？
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "1", Name = "您的小学老师", Value = "您的小学老师？" });
                    list.Add(new DefaultResource() { Code = "2", Name = "您父亲的生日", Value = "您父亲的生日？" });
                    list.Add(new DefaultResource() { Code = "3", Name = "您母亲的生日", Value = "您母亲的生日？" });
                    list.Add(new DefaultResource() { Code = "4", Name = "您的结婚纪念日", Value = "您的结婚纪念日？" });
                    break;
                case "QUESTIONTHREE": // 安全问题1：1您的小学老师？、2您父亲的生日？、3您母亲的生日？、4您的结婚纪念日？
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "1", Name = "您的小学老师", Value = "您的小学老师？" });
                    list.Add(new DefaultResource() { Code = "2", Name = "您父亲的生日", Value = "您父亲的生日？" });
                    list.Add(new DefaultResource() { Code = "3", Name = "您母亲的生日", Value = "您母亲的生日？" });
                    list.Add(new DefaultResource() { Code = "4", Name = "您的结婚纪念日", Value = "您的结婚纪念日？" });
                    break;
                case "TemplateType"://链接类型：1友情链接 2合作伙伴
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "1", Name = "短信模板", Value = "1" });
                    list.Add(new DefaultResource() { Code = "2", Name = "邮件模板", Value = "2" });
                    break;

                case "LinkType"://链接类型：1友情链接 2合作伙伴
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "1", Name = "友情链接", Value = "1" });
                    list.Add(new DefaultResource() { Code = "2", Name = "合作伙伴", Value = "2" });
                    break;
                case "Watermarktype"://图片水印类型
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "0", Name = "关闭水印", Value = "0" });
                    list.Add(new DefaultResource() { Code = "1", Name = "文字水印", Value = "1" });
                    list.Add(new DefaultResource() { Code = "2", Name = "图片水印", Value = "2" });
                    break;
                case "Watermarkposition"://图片水印位置
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "0", Name = "左上", Value = "0" });
                    list.Add(new DefaultResource() { Code = "1", Name = "中上", Value = "1" });
                    list.Add(new DefaultResource() { Code = "2", Name = "右上", Value = "2" });
                    list.Add(new DefaultResource() { Code = "3", Name = "左中", Value = "3" });
                    list.Add(new DefaultResource() { Code = "4", Name = "居中", Value = "4" });
                    list.Add(new DefaultResource() { Code = "5", Name = "右中", Value = "5" });
                    list.Add(new DefaultResource() { Code = "6", Name = "左下", Value = "6" });
                    list.Add(new DefaultResource() { Code = "7", Name = "中下", Value = "7" });
                    list.Add(new DefaultResource() { Code = "8", Name = "右下", Value = "8" });
                    break;

                case "Industry"://行业
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "0", Name = "计算机硬件及网络设备", Value = "0" });
                    list.Add(new DefaultResource() { Code = "1", Name = "计算机软件", Value = "1" });
                    list.Add(new DefaultResource() { Code = "2", Name = "IT服务（系统/数据/维护）/多领域经营", Value = "2" });
                    list.Add(new DefaultResource() { Code = "3", Name = "互联网/电子商务", Value = "3" });
                    list.Add(new DefaultResource() { Code = "4", Name = "网络游戏", Value = "4" });
                    list.Add(new DefaultResource() { Code = "5", Name = "通讯（设备/运营/增值服务）", Value = "5" });
                    list.Add(new DefaultResource() { Code = "6", Name = "电子技术/半导体/集成电路", Value = "6" });
                    list.Add(new DefaultResource() { Code = "7", Name = "仪器仪表及工业自动化", Value = "7" });
                    list.Add(new DefaultResource() { Code = "8", Name = "金融/银行/投资/基金/证券", Value = "8" });
                    list.Add(new DefaultResource() { Code = "9", Name = "保险", Value = "9" });
                    list.Add(new DefaultResource() { Code = "10", Name = "房地产/建筑/建材/工程", Value = "10" });
                    list.Add(new DefaultResource() { Code = "11", Name = "家居/室内设计/装饰装潢", Value = "11" });
                    list.Add(new DefaultResource() { Code = "12", Name = "物业管理/商业中心", Value = "12" });
                    list.Add(new DefaultResource() { Code = "13", Name = "广告/会展/公关/市场推广", Value = "13" });
                    list.Add(new DefaultResource() { Code = "14", Name = "媒体/出版/影视/文化/艺术", Value = "14" });
                    list.Add(new DefaultResource() { Code = "15", Name = "印刷/包装/造纸", Value = "15" });
                    list.Add(new DefaultResource() { Code = "16", Name = "咨询/管理产业/法律/财会", Value = "16" });
                    list.Add(new DefaultResource() { Code = "17", Name = "教育/培训", Value = "17" });
                    list.Add(new DefaultResource() { Code = "18", Name = "检验/检测/认证", Value = "18" });
                    list.Add(new DefaultResource() { Code = "19", Name = "中介服务", Value = "19" });
                    list.Add(new DefaultResource() { Code = "20", Name = "贸易/进出口", Value = "20" });
                    list.Add(new DefaultResource() { Code = "21", Name = "零售/批发", Value = "21" });
                    list.Add(new DefaultResource() { Code = "22", Name = "快速消费品（食品/饮料/烟酒/化妆品", Value = "22" });
                    list.Add(new DefaultResource() { Code = "23", Name = "耐用消费品（服装服饰/纺织/皮革/家具/家电）", Value = "23" });
                    list.Add(new DefaultResource() { Code = "24", Name = "办公用品及设备", Value = "24" });
                    list.Add(new DefaultResource() { Code = "25", Name = "礼品/玩具/工艺美术/收藏品", Value = "25" });
                    list.Add(new DefaultResource() { Code = "26", Name = "大型设备/机电设备/重工业", Value = "26" });
                    list.Add(new DefaultResource() { Code = "27", Name = "加工制造（原料加工/模具）", Value = "27" });
                    list.Add(new DefaultResource() { Code = "28", Name = "汽车/摩托车（制造/维护/配件/销售/服务）", Value = "28" });
                    list.Add(new DefaultResource() { Code = "29", Name = "交通/运输/物流", Value = "29" });
                    list.Add(new DefaultResource() { Code = "30", Name = "医药/生物工程", Value = "30" });
                    list.Add(new DefaultResource() { Code = "31", Name = "医疗/护理/美容/保健", Value = "31" });
                    list.Add(new DefaultResource() { Code = "32", Name = "医疗设备/器械", Value = "32" });
                    list.Add(new DefaultResource() { Code = "33", Name = "酒店/餐饮", Value = "33" });
                    list.Add(new DefaultResource() { Code = "34", Name = "娱乐/体育/休闲", Value = "34" });
                    list.Add(new DefaultResource() { Code = "35", Name = "旅游/度假", Value = "35" });
                    list.Add(new DefaultResource() { Code = "36", Name = "石油/石化/化工", Value = "36" });
                    list.Add(new DefaultResource() { Code = "37", Name = "能源/矿产/采掘/冶炼", Value = "37" });
                    list.Add(new DefaultResource() { Code = "38", Name = "电气/电力/水利", Value = "38" });
                    list.Add(new DefaultResource() { Code = "39", Name = "航空/航天", Value = "39" });
                    list.Add(new DefaultResource() { Code = "40", Name = "学术/科研", Value = "40" });
                    list.Add(new DefaultResource() { Code = "41", Name = "政府/公共事业/非盈利机构", Value = "41" });
                    list.Add(new DefaultResource() { Code = "42", Name = "环保", Value = "42" });
                    list.Add(new DefaultResource() { Code = "43", Name = "农/林/牧/渔", Value = "43" });
                    list.Add(new DefaultResource() { Code = "44", Name = "跨领域经营", Value = "44" });
                    list.Add(new DefaultResource() { Code = "45", Name = "其它", Value = "45" });
                    break;

                case "Watermarkfont"://字体
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "Arial", Name = "Arial", Value = "Arial" });
                    list.Add(new DefaultResource() { Code = "Arial Black", Name = "Arial Black", Value = "Arial Black" });
                    list.Add(new DefaultResource() { Code = "Batang", Name = "Batang", Value = "Batang" });
                    list.Add(new DefaultResource() { Code = "Comic Sans MS", Name = "Comic Sans MS", Value = "Comic Sans MS" });
                    list.Add(new DefaultResource() { Code = "Courier New", Name = "Courier New", Value = "Courier New" });
                    list.Add(new DefaultResource() { Code = "Dotum", Name = "Dotum", Value = "Dotum" });
                    list.Add(new DefaultResource() { Code = "DotumChe", Name = "DotumChe", Value = "DotumChe" });
                    list.Add(new DefaultResource() { Code = "Estrangelo Edessa", Name = "Estrangelo Edessa", Value = "Estrangelo Edessa" });
                    list.Add(new DefaultResource() { Code = "Franklin Gothic Medium", Name = "Franklin Gothic Medium", Value = "Franklin Gothic Medium" });
                    list.Add(new DefaultResource() { Code = "Gautami", Name = "Gautami", Value = "Gautami" });
                    list.Add(new DefaultResource() { Code = "Georgia", Name = "Georgia", Value = "Georgia" });
                    list.Add(new DefaultResource() { Code = "Gulim", Name = "Gulim", Value = "Gulim" });
                    list.Add(new DefaultResource() { Code = "GulimChe", Name = "GulimChe", Value = "GulimChe" });
                    list.Add(new DefaultResource() { Code = "Gungsuh", Name = "Gungsuh", Value = "Gungsuh" });
                    list.Add(new DefaultResource() { Code = "GungsuhChe", Name = "GungsuhChe", Value = "GungsuhChe" });
                    list.Add(new DefaultResource() { Code = "Impact", Name = "Impact", Value = "Impact" });
                    list.Add(new DefaultResource() { Code = "Latha", Name = "Latha", Value = "Latha" });
                    list.Add(new DefaultResource() { Code = "Lucida Console", Name = "Lucida Console", Value = "Lucida Console" });
                    list.Add(new DefaultResource() { Code = "Lucida Sans Unicode", Name = "Lucida Sans Unicode", Value = "Lucida Sans Unicode" });
                    list.Add(new DefaultResource() { Code = "Marlett", Name = "Marlett", Value = "Marlett" });
                    list.Add(new DefaultResource() { Code = "Microsoft Sans Serif", Name = "Microsoft Sans Serif", Value = "Microsoft Sans Serif" });
                    list.Add(new DefaultResource() { Code = "MingLiU", Name = "MingLiU", Value = "MingLiU" });
                    list.Add(new DefaultResource() { Code = "MS Gothic", Name = "MS Gothic", Value = "MS Gothic" });
                    list.Add(new DefaultResource() { Code = "MS Mincho", Name = "MS Mincho", Value = "MS Mincho" });
                    list.Add(new DefaultResource() { Code = "MS PGothic", Name = "MS PGothic", Value = "MS PGothic" });
                    list.Add(new DefaultResource() { Code = "MS PMincho", Name = "MS PMincho", Value = "MS PMincho" });
                    list.Add(new DefaultResource() { Code = "MS UI Gothic", Name = "MS UI Gothic", Value = "MS UI Gothic" });
                    list.Add(new DefaultResource() { Code = "Palatino Linotype", Name = "Palatino Linotype", Value = "Palatino Linotype" });
                    list.Add(new DefaultResource() { Code = "MV Boli", Name = "MV Boli", Value = "MV Boli" });
                    list.Add(new DefaultResource() { Code = "PMingLiU", Name = "PMingLiU", Value = "PMingLiU" });
                    list.Add(new DefaultResource() { Code = "Raavi", Name = "Raavi", Value = "Raavi" });
                    list.Add(new DefaultResource() { Code = "Shruti", Name = "Shruti", Value = "Shruti" });
                    list.Add(new DefaultResource() { Code = "Sylfaen", Name = "Sylfaen", Value = "Sylfaen" });
                    list.Add(new DefaultResource() { Code = "Symbol", Name = "Symbol", Value = "Symbol" });
                    list.Add(new DefaultResource() { Code = "Tahoma", Name = "Tahoma", Value = "Tahoma" });
                    list.Add(new DefaultResource() { Code = "Times New Roman", Name = "Times New Roman", Value = "Times New Roman" });
                    list.Add(new DefaultResource() { Code = "Trebuchet MS", Name = "Trebuchet MS", Value = "Trebuchet MS" });
                    list.Add(new DefaultResource() { Code = "Tunga", Name = "Tunga", Value = "Tunga" });
                    list.Add(new DefaultResource() { Code = "Verdana", Name = "Verdana", Value = "Verdana" });
                    list.Add(new DefaultResource() { Code = "Webdings", Name = "Webdings", Value = "Webdings" });
                    list.Add(new DefaultResource() { Code = "Wingdings", Name = "Wingdings", Value = "Wingdings" });
                    list.Add(new DefaultResource() { Code = "仿宋_GB2312", Name = "仿宋_GB2312", Value = "仿宋_GB2312" });
                    list.Add(new DefaultResource() { Code = "宋体", Name = "宋体", Value = "宋体" });
                    list.Add(new DefaultResource() { Code = "新宋体", Name = "新宋体", Value = "新宋体" });
                    list.Add(new DefaultResource() { Code = "楷体_GB2312", Name = "楷体_GB2312", Value = "楷体_GB2312" });
                    list.Add(new DefaultResource() { Code = "黑体", Name = "黑体", Value = "黑体" });
                    break;


                case "Nature"://公司性质
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "0", Name = "政府机关/事业单位", Value = "0" });
                    list.Add(new DefaultResource() { Code = "1", Name = "国营", Value = "1" });
                    list.Add(new DefaultResource() { Code = "2", Name = "私营", Value = "2" });
                    list.Add(new DefaultResource() { Code = "3", Name = "中外合资", Value = "3" });
                    list.Add(new DefaultResource() { Code = "4", Name = "外资", Value = "4" });
                    list.Add(new DefaultResource() { Code = "5", Name = "其他", Value = "5" });
                    break;

                case "Status": //(页面状态显示) 审核状态：0待审核、1审核不通过、2审核通过
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "0", Name = "未认证", Value = "0" });
                    list.Add(new DefaultResource() { Code = "1", Name = "审核中", Value = "1" });
                    list.Add(new DefaultResource() { Code = "2", Name = "已认证", Value = "2" });
                    list.Add(new DefaultResource() { Code = "3", Name = "未通过", Value = "3" });
                    break;

                case "Status1": //（后台查询下拉框） 审核状态：0待审核、1审核不通过、2审核通过
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "0", Name = "—请选择—", Value = "0" });
                    list.Add(new DefaultResource() { Code = "1", Name = "审核中", Value = "1" });
                    list.Add(new DefaultResource() { Code = "2", Name = "已认证", Value = "2" });
                    break;

                case "Status2": //（后台审核下拉框） 审核状态：0待审核、1审核不通过、2审核通过
                    list = new List<IResource>();

                    list.Add(new DefaultResource() { Code = "2", Name = "已认证", Value = "2" });
                    list.Add(new DefaultResource() { Code = "3", Name = "未通过", Value = "3" });
                    break;

                //case "ProjectClass"://项目类型
                //    list = new List<IResource>();
                //    list.Add(new DefaultResource() { Code = "0", Name = "回报众筹", Value = "1" });
                //    list.Add(new DefaultResource() { Code = "1", Name = "公益捐助众筹", Value = "2" });
                //    break;
                case "ProjectType"://众筹项目分类
                    list = new List<IResource>();
                    var plist = dRepo.GetProjectType();
                    list = plist.ConvertAll<IResource>(x =>
                    {
                        return new DefaultResource() { Code = x.Id.ToString(), Name = x.Name, Value = x.Id.ToString() };
                    });
                    break;

                case "RedoundType"://回报类型
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "0", Name = "实物回报", Value = "0" });
                    list.Add(new DefaultResource() { Code = "1", Name = "虚拟物品回报(电子码等)", Value = "1" });
                    break;

                case "CustomerService"://部门
                    list = new List<IResource>();
                    var ulist = dRepo.GetUser();
                    list = ulist.ConvertAll<IResource>(x =>
                    {
                        return new DefaultResource() { Code = x.ID.ToString(), Name = x.UserName, Value = x.ID.ToString() };
                    });

                    break;
                case "DepartMent"://部门
                    list = new List<IResource>();
                    var blist = dRepo.GetDepartMent();
                    list = blist.ConvertAll<IResource>(x =>
                    {
                        return new DefaultResource() { Code = x.ID.ToString(), Name = x.Name, Value = x.ID.ToString() };
                    });

                    break;
                case "DepartMentTree"://部门树
                    list = new List<IResource>();
                    var dmtlist = dRepo.GetDepartMent();
                    list = dmtlist.ConvertAll<IResource>(x =>
                    {
                        return new DefaultResource() { Code = x.ID.ToString(), Name = x.Name, Value = x.ID.ToString() };
                    });

                    break;
                case "Module"://模块
                    list = new List<IResource>();
                    var mlist = dRepo.GetModule();
                    list = mlist.ConvertAll<IResource>(x =>
                    {
                        return new DefaultResource() { Code = x.ID.ToString(), Name = x.Name, Value = x.ID.ToString() };
                    });

                    break;
                case "ModuleTree"://模块树
                    list = new List<IResource>();
                    var mtlist = dRepo.GetModule();
                    list = mtlist.ConvertAll<IResource>(x =>
                    {
                        for (int i = 0; i < x.Layer; i++)
                        {
                            x.Name = "　　" + x.Name;
                        }
                        //x.Name = 
                        return new DefaultResource() { Code = x.ID.ToString(), Name = x.Name, Value = x.ID.ToString() };
                    });

                    break;
                case "IDType": //证件类型：1身份证 2护照 3军官证 4港澳台往来大陆通行证
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "1", Name = "身份证", Value = "1" });
                    list.Add(new DefaultResource() { Code = "2", Name = "护照", Value = "2" });
                    list.Add(new DefaultResource() { Code = "3", Name = "军官证", Value = "3" });
                    list.Add(new DefaultResource() { Code = "4", Name = "港澳台往来大陆通行证", Value = "4" });
                    break;

                case "ReceiveFileType": //接收文件方式：1信件 2电子邮件 3两者都选
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "1", Name = "信件", Value = "1" });
                    list.Add(new DefaultResource() { Code = "2", Name = "电子邮件", Value = "2" });
                    list.Add(new DefaultResource() { Code = "3", Name = "两者都选", Value = "3" });
                    break;





                case "Province": //省
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "110000000000", Name = "北京", Value = "110000000000" });
                    list.Add(new DefaultResource() { Code = "120000000000", Name = "天津", Value = "120000000000" });
                    list.Add(new DefaultResource() { Code = "130000000000", Name = "河北", Value = "120000000000" });
                    list.Add(new DefaultResource() { Code = "140000000000", Name = "山西", Value = "140000000000" });
                    list.Add(new DefaultResource() { Code = "150000000000", Name = "内蒙古", Value = "150000000000" });
                    list.Add(new DefaultResource() { Code = "210000000000", Name = "辽宁", Value = "210000000000" });
                    list.Add(new DefaultResource() { Code = "220000000000", Name = "吉林", Value = "220000000000" });
                    list.Add(new DefaultResource() { Code = "230000000000", Name = "黑龙江", Value = "230000000000" });
                    list.Add(new DefaultResource() { Code = "310000000000", Name = "上海", Value = "310000000000" });
                    list.Add(new DefaultResource() { Code = "320000000000", Name = "江苏", Value = "320000000000" });
                    list.Add(new DefaultResource() { Code = "330000000000", Name = "浙江", Value = "330000000000" });
                    list.Add(new DefaultResource() { Code = "340000000000", Name = "安徽", Value = "340000000000" });
                    list.Add(new DefaultResource() { Code = "350000000000", Name = "福建", Value = "350000000000" });
                    list.Add(new DefaultResource() { Code = "360000000000", Name = "江西", Value = "360000000000" });
                    list.Add(new DefaultResource() { Code = "370000000000", Name = "山东", Value = "370000000000" });
                    list.Add(new DefaultResource() { Code = "410000000000", Name = "河南", Value = "410000000000" });
                    list.Add(new DefaultResource() { Code = "420000000000", Name = "湖北", Value = "420000000000" });
                    list.Add(new DefaultResource() { Code = "430000000000", Name = "湖南", Value = "430000000000" });
                    list.Add(new DefaultResource() { Code = "440000000000", Name = "广东", Value = "440000000000" });
                    list.Add(new DefaultResource() { Code = "450000000000", Name = "广西", Value = "450000000000" });
                    list.Add(new DefaultResource() { Code = "460000000000", Name = "海南", Value = "460000000000" });
                    list.Add(new DefaultResource() { Code = "500000000000", Name = "重庆", Value = "500000000000" });
                    list.Add(new DefaultResource() { Code = "510000000000", Name = "四川", Value = "510000000000" });
                    list.Add(new DefaultResource() { Code = "520000000000", Name = "贵州", Value = "520000000000" });
                    list.Add(new DefaultResource() { Code = "530000000000", Name = "云南", Value = "530000000000" });
                    list.Add(new DefaultResource() { Code = "540000000000", Name = "西藏", Value = "540000000000" });
                    list.Add(new DefaultResource() { Code = "610000000000", Name = "陕西", Value = "610000000000" });
                    list.Add(new DefaultResource() { Code = "620000000000", Name = "甘肃", Value = "620000000000" });
                    list.Add(new DefaultResource() { Code = "630000000000", Name = "青海", Value = "630000000000" });
                    list.Add(new DefaultResource() { Code = "640000000000", Name = "宁夏", Value = "640000000000" });
                    list.Add(new DefaultResource() { Code = "650000000000", Name = "新疆", Value = "650000000000" });
                    list.Add(new DefaultResource() { Code = "710000000000", Name = "台湾", Value = "710000000000" });
                    list.Add(new DefaultResource() { Code = "810000000000", Name = "香港特别行政区", Value = "810000000000" });
                    list.Add(new DefaultResource() { Code = "820000000000", Name = "澳门特别行政区", Value = "820000000000" });

                    break;
                case "City": //市
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "1", Name = "浦东新区", Value = "1" });
































                    break;
                case "Bank": //开户行
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "1", Name = "招商银行", Value = "招商银行" });
                    list.Add(new DefaultResource() { Code = "2", Name = "建设银行", Value = "建设银行" });
                    list.Add(new DefaultResource() { Code = "3", Name = "中国银行", Value = "中国银行" });
                    list.Add(new DefaultResource() { Code = "4", Name = "中国工商银行", Value = "中国工商银行" });
                    list.Add(new DefaultResource() { Code = "5", Name = "中国农业银行", Value = "中国农业银行" });
                    list.Add(new DefaultResource() { Code = "6", Name = "中国光大银行", Value = "中国光大银行" });
                    list.Add(new DefaultResource() { Code = "7", Name = "浦发银行", Value = "浦发银行" });
                    list.Add(new DefaultResource() { Code = "8", Name = "上海银行", Value = "上海银行" });
                    list.Add(new DefaultResource() { Code = "9", Name = "交通银行", Value = "交通银行" });
                    list.Add(new DefaultResource() { Code = "10", Name = "兴业银行", Value = "兴业银行" });
                    list.Add(new DefaultResource() { Code = "11", Name = "中信银行", Value = "中信银行" });
                    list.Add(new DefaultResource() { Code = "12", Name = "广发银行", Value = "广发银行" });
                    list.Add(new DefaultResource() { Code = "13", Name = "平安银行", Value = "平安银行" });
                    list.Add(new DefaultResource() { Code = "14", Name = "北京银行", Value = "北京银行" });
                    list.Add(new DefaultResource() { Code = "15", Name = "广州银行", Value = "广州银行" });
                    list.Add(new DefaultResource() { Code = "16", Name = "南京银行", Value = "南京银行" });
                    list.Add(new DefaultResource() { Code = "17", Name = "宁波银行", Value = "宁波银行" });
                    list.Add(new DefaultResource() { Code = "18", Name = "华夏银行", Value = "华夏银行" });
                    list.Add(new DefaultResource() { Code = "19", Name = "徽商银行", Value = "徽商银行" });
                    list.Add(new DefaultResource() { Code = "20", Name = "浙商银行", Value = "浙商银行" });
                    list.Add(new DefaultResource() { Code = "21", Name = "农村商业银行", Value = "农村商业银行" });
                    list.Add(new DefaultResource() { Code = "22", Name = "北京农商银行", Value = "北京农商银行" });
                    list.Add(new DefaultResource() { Code = "23", Name = "深圳发展银行", Value = "深圳发展银行" });
                    list.Add(new DefaultResource() { Code = "24", Name = "中国邮政储蓄银行", Value = "中国邮政储蓄银行" });

                    break;
                case "DurationMonthOrDay":
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "1", Name = "月份", Value = "1" });
                    list.Add(new DefaultResource() { Code = "2", Name = "天数", Value = "2" });
                    break;
                case "PURCHASE":
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "0", Name = "否", Value = "0" });
                    list.Add(new DefaultResource() { Code = "1", Name = "是", Value = "1" });
                    break;
                case "IsNewProject":
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "0", Name = "否", Value = "0" });
                    list.Add(new DefaultResource() { Code = "1", Name = "是", Value = "1" });
                    break;
                case "RepaymentType":
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "1", Name = "付息还本", Value = "1" });
                    list.Add(new DefaultResource() { Code = "2", Name = "一次性还款", Value = "2" });
                    list.Add(new DefaultResource() { Code = "3", Name = "等额本息", Value = "3" });
                    break;
                case "MenuTree"://模块树
                    list = new List<IResource>();
                    var menutlist = dRepo.GetMenu();
                    list = menutlist.ConvertAll<IResource>(x =>
                    {
                        for (int i = 0; i < x.Layer; i++)
                        {
                            x.Name = "　　" + x.Name;
                        }
                        //x.Name = 
                        return new DefaultResource() { Code = x.ID.ToString(), Name = x.Name, Value = x.ID.ToString() };
                    });

                    break;

                case "User"://理财经理
                    list = new List<IResource>();
                    var userlist = dRepo.GetUser();
                    list = userlist.ConvertAll<IResource>(x =>
                    {
                        return new DefaultResource() { Code = x.ID.ToString(), Name = x.UserName, Value = x.ID.ToString() };
                    });
                    break;

                case "BankCard"://银行卡 这里key 和 value 都是同一个 因为存在数据库中是bankName
                    list = new List<IResource>();
                    var bclist = dRepo.GetBankName();
                    list = bclist.ConvertAll<IResource>(x =>
                    {
                        return new DefaultResource() { Code = x.Id.ToString(), Name = x.BankName, Value = x.BankCode };

                    });
                    break;

                case "ProjectClass"://众筹项目分类
                    list = new List<IResource>();
                    var pclist = dRepo.GetProjectClassName();
                    list = pclist.ConvertAll<IResource>(x =>
                    {
                        return new DefaultResource() { Code = x.Id.ToString(), Name = x.Name, Value = x.Id.ToString() };
                    });
                    break;

                case "NeedInvoice"://是否需要发票
                    list = new List<IResource>();
                    list.Add(new DefaultResource() { Code = "0", Name = "无需发票", Value = "0" });
                    list.Add(new DefaultResource() { Code = "1", Name = "需要发票", Value = "1" });
                    break;


            }
            if (list != null)
            {
                CacheFactory.Instance.CreateCoreCacheInstance().Insert("RESOURCE_" + code + "_" + parentCode, list);
            }
            if (hasAllOption)
                list.Insert(0, new DefaultResource() { Code = null, Name = "-----请选择-----", Value = null });
            return list;
        }
    }

    [DataContract]
    public class DefaultResource : IResource
    {
        [DataMember(Name = "code")]
        public string Code
        {
            get;
            set;
        }
        [DataMember(Name = "name")]
        public string Name
        {
            get;
            set;
        }
        [DataMember(Name = "value")]
        public string Value
        {
            get;
            set;
        }
    }
}
